<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Http\Controllers\ScheduleController;

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's command schedule.
     *
     * @param Schedule $schedule
     */
    protected function schedule(Schedule $schedule): void
    {
        // 每天定时更新一次关注列表中最高点和最低点的价格
        $schedule->call(function () {
            $scheduleCtl = new ScheduleController();
            $scheduleCtl->updateHightestAndLowestPrice();
        })
            ->dailyAt('15:15');

        // 每天开盘时间没分钟更新关注列表中被监听的价格

        $schedule->call(function () {
            $scheduleCtl = new ScheduleController();
            $scheduleCtl->monitor();
        })
            ->everyMinute();
    }

    /**
     * Register the commands for the application.
     */
    protected function commands(): void
    {
        $this->load(__DIR__ . '/Commands');

        \App\Console\Commands\WxCouponConsumeStatusUpdate::class;
        \App\Console\Commands\WxCouponAutoSend::class;

        require base_path('routes/console.php');
    }
}
